import mongoose, { Document, Schema } from 'mongoose';

export interface IOrder extends Document {
    user: any; // 用户引用
    product: any; // 商品引用
    productType: string; // 商品类型
    quantity: number; // 商品数量
    totalAmount: number; // 订单总金额
    payMethod: number; // 订单总金额
    status: string; // 订单状态
    remark: string; // 订单状态
    payInfo: any; // 支付信息
    createdAt: string; // 创建时间
    updatedAt: string; // 更新时间
}

const OrderSchema: Schema = new Schema({
    user: { type: Object, required: true },
    product: { type: Object, required: true },
    productType: { type: String },
    quantity: { type: Number, required: true, default: 1 },
    totalAmount: { type: Number, required: true },
    payMethod: { type: String },
    status: { type: String, required: true, default: 'pending' },
    remark: { type: String, default: '' },
    payInfo: { type: Object, },
    createdAt: { type: String },
    updatedAt: { type: String }
});

export default mongoose.model<IOrder>('Order', OrderSchema);
